package org.wu.framework.authorization.platform.application.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.wu.framework.authorization.platform.application.SysUserRoleApplication;
import org.wu.framework.authorization.platform.application.assembler.SysUserRoleDTOAssembler;
import org.wu.framework.authorization.platform.application.command.SysUserRoleCommand;
import org.wu.framework.authorization.platform.domain.model.sys.user.role.SysUserRole;
import org.wu.framework.authorization.platform.domain.model.sys.user.role.SysUserRoleRepository;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;

import java.util.List;

/**
 * describe 用户角色关联关系
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyApplicationImpl
 **/
@LazyApplication
public class SysUserRoleApplicationImpl implements SysUserRoleApplication {

    @Autowired
    SysUserRoleRepository sysUserRoleRepository;

    /**
     * describe 新增用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysUserRole> save(SysUserRoleCommand sysUserRoleCommand) {
        SysUserRole sysUserRole = SysUserRoleDTOAssembler.toUserRole(sysUserRoleCommand);
        return sysUserRoleRepository.story(sysUserRole);
    }

    /**
     * describe 更新用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysUserRole> update(SysUserRoleCommand sysUserRoleCommand) {
        SysUserRole sysUserRole = SysUserRoleDTOAssembler.toUserRole(sysUserRoleCommand);
        return sysUserRoleRepository.story(sysUserRole);
    }

    /**
     * describe 查询单个用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysUserRole> findOne(SysUserRoleCommand sysUserRoleCommand) {
        SysUserRole sysUserRole = SysUserRoleDTOAssembler.toUserRole(sysUserRoleCommand);
        return sysUserRoleRepository.findOne(sysUserRole);
    }

    /**
     * describe 查询多个用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<List<SysUserRole>> findList(SysUserRoleCommand sysUserRoleCommand) {
        SysUserRole sysUserRole = SysUserRoleDTOAssembler.toUserRole(sysUserRoleCommand);
        return sysUserRoleRepository.findList(sysUserRole);
    }

    /**
     * describe 删除用户角色关联关系
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysUserRole> delete(SysUserRoleCommand sysUserRoleCommand) {
        SysUserRole sysUserRole = SysUserRoleDTOAssembler.toUserRole(sysUserRoleCommand);
        return sysUserRoleRepository.delete(sysUserRole);
    }

}